import 'dart:convert';
import 'package:bilibili/http/request/base_request.dart';

abstract class HiNetAdapter {
  // 如果函数参数或返回值中存才泛型类型，
  // 函数声明必须包含该泛型的声明，如send<T>
  Future<HiNetResponse<T>> send<T>(BaseRequest request);
}

class HiNetResponse<T> {
  HiNetResponse({this.data, required this.request, this.statusCode});

  T? data;
  BaseRequest request;
  int? statusCode;
  dynamic extra;

  @override
  String toString() {
    if (data is Map) {
      return json.encode(data);
    }
    return data.toString();
  }
}
